Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Support of converting local models added to convert-hf-to-gguf-update.py #7547

Merged
merged 4 commits into from
Sep 11, 2024

Conversation

EvilFreelancer
Copy link
Contributor

Description

For one of my projects, I needed to convert a trained BERT model, which was only available on my local filesystem. However, when I attempted the conversion, I encountered an error indicating that my tokenizer was not supported. To resolve this, I added my local model and its filesystem path to the models array, but running the convert-hf-to-gguf-update.py script did not update convert-hf-to-gguf.py as expected.

The root cause was identified in the download_model function. The current implementation only supports downloading models hosted on HuggingFace.

But my fix extends this functionality to also support models stored locally.

Changes Made

  • Modified the download_model function to check if the repo path is a local directory.
  • If repo is a local path, the function now copies the required files from the local directory to the appropriate destination.
  • If repo is a URL, the function retains its original behavior of downloading the files from HuggingFace.

Example Usage

To convert a local model, you can now add it to the models array of convert-hf-to-gguf-update.py with the local filesystem path:

models = [
    {"name": "sbert", "tokt": TOKENIZER_TYPE.WPM, "repo": "./sbert_large_nlu_ru"},
    ...
    ...
]

Run it:

python convert-hf-to-gguf-update.py <hf_token>

And new block will be added to convert-hf-to-gguf.py, it will looks like this:

if chkhsh == "eb70cf7b9840b5efff6c673f695000d9a0195852c07a45a3e61718fcbaddf601":
    # ref: ./sbert_large_nlu_ru
    res = "sbert"

After than you will be able to convert local model to the GGUF format.

@github-actions github-actions bot added the python python script changes label May 26, 2024
convert-hf-to-gguf-update.py Outdated Show resolved Hide resolved
@mofosyne mofosyne added the Review Complexity : Low Trivial changes to code that most beginner devs (or those who want a break) can tackle. e.g. UI fix label May 27, 2024
@EvilFreelancer
Copy link
Contributor Author

EvilFreelancer commented Sep 11, 2024

Hi! Any news about my PR? People need this simple feature :)

Copy link
Owner

@ggerganov ggerganov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can merge after rebasing on latest master

@EvilFreelancer
Copy link
Contributor Author

@ggerganov hi! You mean I need to merge master branch into this feature branch?

@ggerganov
Copy link
Owner

Yes. The convert-hf-to-gguf-update.py file was renamed at some point to convert_hf_to_gguf_update.py and so there is a merge conflict preventing the merging of the PR. After you resolve it, we will be able to merge.

@EvilFreelancer
Copy link
Contributor Author

Done, i've also tested this new feature by hands, it works fine.

@ggerganov ggerganov merged commit 8db003a into ggerganov:master Sep 11, 2024
9 checks passed
dsx1986 pushed a commit to dsx1986/llama.cpp that referenced this pull request Oct 29, 2024
* Support of converting local models added to convert-hf-to-gguf-update.py

* Description fixed

* shutil added to imports
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Nov 15, 2024
* Support of converting local models added to convert-hf-to-gguf-update.py

* Description fixed

* shutil added to imports
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Nov 18, 2024
* Support of converting local models added to convert-hf-to-gguf-update.py

* Description fixed

* shutil added to imports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python python script changes Review Complexity : Low Trivial changes to code that most beginner devs (or those who want a break) can tackle. e.g. UI fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants